#include "String.h"

void Test()
{
	string s1("hello");
	string s2(s1);

	s1.resize(10);
	s1.resize(20, 't');
	s2.resize(3);
	cout << s1 << endl;
	cout << s2 << endl;
	string s3;
	s3.reserve(20);
	s1.reserve(3);

	s2.clear();

	size_t index = s1.find('a', 10);
	index = s1.find('\0');

	string s4("hello world");
	string s5(s4);
	s5 += "!!!hello";
	s5.erase(11);
	s5 += ' ';
	string s6("hello x");

	cout << (s4 == s6) << endl;
	cout << (s4 < s6) << endl;
	cout << (s4 > s6) << endl;

}

void Test1()
{
	wzw::string s1("hello world");
	wzw::string s2;
	wzw::string s3(s1);
	cout << s1.size() << endl;
	cout << s1.capacity() << endl;
	cout << s1.empty() << endl;
	cout << s2.empty() << endl;

	s1.reserve(5);
	s1.reserve(20);

	s3.resize(15);

	wzw::string s4("hello world!");
	wzw::string s5 = s4;
	s1 = s4;
}
void Test2()
{
	wzw::string s1("hello world!!!");
	for (size_t i = 0; i < s1.size(); ++i)
	{
		cout << s1[i];
	}
	cout << endl;

	wzw::string::iterator it = s1.begin();
	while (it != s1.end())
	{
		cout << *it;
		++it;
	}
	cout << endl;

	it = s1.begin();
	while (it != s1.end())
	{
		(*it)++;
		cout << *it;
		++it;
	}
	cout << endl;

	for (auto ch : s1)
	{
		cout << ch;
	}
	cout << endl;
	for (auto& ch : s1)
	{
		--ch;
		cout << ch;
	}
	cout << endl;
}
void Test3()
{
	wzw::string s1("hello world");
	wzw::string s3(s1);
	s1.push_back('!');
	
	wzw::string s2;
	s2.push_back('a');

	s3.append("!!!");

	wzw::string s4;
	s4.append("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

	wzw::string s5(s1);
	s5 += "!!";
	s5 += 't';

	s5.clear();

	s1.swap(s4);
}
void Test4()
{
	wzw::string s1("hello world!");

	size_t index = s1.find('h');
	index = s1.find('l');
	index = s1.find('!');
	index = s1.find('\0');
	index = s1.find('c');

	index = s1.find("wor", 7);
	index = s1.find("wor", 20);
	index = s1.find("hel");

	s1.insert(5, 't');
	s1.insert(13, 't');
	s1.insert(0, 't');
	//s1.insert(-1, 't');

	wzw::string s2;
	s2.insert(0, "hello");
	s2.insert(5, " world!!!");
	s2.insert(5, " hehe");

	cout << s2 << endl;

}
void Test5()
{
	/*wzw::string s;
	cin >> s;
	cout << s << endl;*/

	wzw::string s1("hello world");

	/*s1.erase(10, 3);
	for (auto ch : s1)
	{
		cout << ch;
	}*/

	wzw::string s2(s1);
	s2 += "!!!hello";
	s2.erase(11);

	wzw::string s3("hello x");

	cout << (s1 == s3) << endl;
	cout << (s1 < s3) << endl;
	cout << (s1 > s3) << endl;

	wzw::string s4 = s1;

}
void Test6()
{
	wzw::string s1("test string");
	auto it1 = s1.cbegin();
	while (it1 != s1.cend())
	{
		//++(*it1);
		cout << *it1;
		++it1;
	}
	cout << endl;

	std::string str("Lorem ipsum");
	for (auto it = str.cbegin(); it != str.cend(); ++it)
	{
		//(*it)++;
		std::cout << *it;
	}
	std::cout << '\n';
}
int main()
{
	//Test();
	//Test1();
	//Test2();
	//Test3();
	//Test4();
	//Test5();
	//Test6();
	wzw::test_rit();

	//const char* str = "hello";
	//cout << str;

	return 0;
}